/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.fh.itsbankomat.businesslogic.model;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author MeinLaptop
 */
@Entity
@Table(name = "BANKOMATKARTE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Bankomatkarte.findAll", query = "SELECT b FROM Bankomatkarte b"),
    @NamedQuery(name = "Bankomatkarte.findByKartenid", query = "SELECT b FROM Bankomatkarte b WHERE b.bankomatkartePK.kartenid = :kartenid"),
    @NamedQuery(name = "Bankomatkarte.findByIban", query = "SELECT b FROM Bankomatkarte b WHERE b.bankomatkartePK.iban = :iban"),
    @NamedQuery(name = "Bankomatkarte.findByBic", query = "SELECT b FROM Bankomatkarte b WHERE b.bankomatkartePK.bic = :bic"),
    @NamedQuery(name = "Bankomatkarte.findByKundeid", query = "SELECT b FROM Bankomatkarte b WHERE b.bankomatkartePK.kundeid = :kundeid"),
    @NamedQuery(name = "Bankomatkarte.findByGesperrt", query = "SELECT b FROM Bankomatkarte b WHERE b.gesperrt = :gesperrt"),
    @NamedQuery(name = "Bankomatkarte.findBySummemaxabhebung", query = "SELECT b FROM Bankomatkarte b WHERE b.summemaxabhebung = :summemaxabhebung"),
    @NamedQuery(name = "Bankomatkarte.findByPin", query = "SELECT b FROM Bankomatkarte b WHERE b.pin = :pin")})
public class Bankomatkarte implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected BankomatkartePK bankomatkartePK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "GESPERRT")
    private Character gesperrt;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "SUMMEMAXABHEBUNG")
    private BigDecimal summemaxabhebung;
    @Size(max = 4)
    @Column(name = "PIN")
    private String pin;
    @JoinColumns({
        @JoinColumn(name = "IBAN", referencedColumnName = "IBAN", insertable = false, updatable = false),
        @JoinColumn(name = "BIC", referencedColumnName = "BIC", insertable = false, updatable = false),
        @JoinColumn(name = "KUNDEID", referencedColumnName = "KUNDEID", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Konto konto;

    public Bankomatkarte() {
    }

    public Bankomatkarte(BankomatkartePK bankomatkartePK) {
        this.bankomatkartePK = bankomatkartePK;
    }

    public Bankomatkarte(BankomatkartePK bankomatkartePK, Character gesperrt) {
        this.bankomatkartePK = bankomatkartePK;
        this.gesperrt = gesperrt;
    }

    public Bankomatkarte(int kartenid, String iban, String bic, int kundeid) {
        this.bankomatkartePK = new BankomatkartePK(kartenid, iban, bic, kundeid);
    }

    public BankomatkartePK getBankomatkartePK() {
        return bankomatkartePK;
    }

    public void setBankomatkartePK(BankomatkartePK bankomatkartePK) {
        this.bankomatkartePK = bankomatkartePK;
    }

    public Character getGesperrt() {
        return gesperrt;
    }

    public void setGesperrt(Character gesperrt) {
        this.gesperrt = gesperrt;
    }

    public BigDecimal getSummemaxabhebung() {
        return summemaxabhebung;
    }

    public void setSummemaxabhebung(BigDecimal summemaxabhebung) {
        this.summemaxabhebung = summemaxabhebung;
    }

    public String getPin() {
        return pin;
    }

    public void setPin(String pin) {
        this.pin = pin;
    }

    public Konto getKonto() {
        return konto;
    }

    public void setKonto(Konto konto) {
        this.konto = konto;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (bankomatkartePK != null ? bankomatkartePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Bankomatkarte)) {
            return false;
        }
        Bankomatkarte other = (Bankomatkarte) object;
        if ((this.bankomatkartePK == null && other.bankomatkartePK != null) || (this.bankomatkartePK != null && !this.bankomatkartePK.equals(other.bankomatkartePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.fh.itsbankomat.businesslogic.model.Bankomatkarte[ bankomatkartePK=" + bankomatkartePK + " ]";
    }
    
}
